<template>
  <div class="main_box">
    <!-- Title -->
    <top_title :formConfig="formConfig">
      <div slot="button">
        <el-button size="small" type="primary" @click="getlist(true)">搜索</el-button>
        <el-button size="small" @click="refresh">刷新</el-button>
      </div>
    </top_title>
    <!-- Table -->
    <el-card>
      <table-list :columns="tableColumns" :tableData="group_list" :pageObj="pageObj" :loading="loading" :type="false"
        @handleCurrentChange="handleCurrentChange" @handleSelectionChange="handleSelectionChange" :btnlong="'200'">
        <template #header="slotProps">
          <el-button size="small" type="text" @click="look(slotProps.date)">详情</el-button>
        </template>
      </table-list>
    </el-card>
  </div>
</template>

<script>
import {
  getloglist
} from "@/api/main/log";
import list from './log.json'
export default {
  name: "",
  components: {},
  data() {
    return {
      // 列表加载状态
      loading: true,
      // 列表类型
      tableColumns: list.tableColumns,
      // 列表数据
      group_list: [],
      //分页参数
      pageObj: {
        size: 10,
        currentPage: 1, //前往当前页
        total: 100
      },
      // 搜索栏
      formConfig: list.formConfig,
      rules: list.rules,
    };
  },
  created() {
    this.getlist(true);
  },
  mounted() { },
  methods: {
    refresh() {
      this.formConfig.form.daterange = []
      this.getlist(true);
    },
    // 首次获取
    getlist(val) {
      if (val) {
        this.pageObj.currentPage = 1
      }
      let start = ""
      let end = ""
      if (this.formConfig.form.daterange.length > 0) {
        start = this.formConfig.form.daterange[0] + ' 00:00:00'
        end = this.formConfig.form.daterange[1] + ' 23:59:59'
      }
      this.loading = true
      let params = {
        page: this.pageObj.currentPage,
        page_size: this.pageObj.size,
        start_time: start,
        over_time: end
      }
      getloglist(params)
        .then((res) => {
          if (res.status == 1) {
            this.group_list = res.data;
            this.pageObj.total = res.total
            this.loading = false
          } else {
            this.loading = false
          }
        })
        .catch((err) => {
          this.loading = false
        });
    },
    // 查看
    look(val) {
      console.log(val, "详情信息")
    },
    // 多选
    handleSelectionChange(val) {
      console.log(val)
    },
    // 页码选择
    handleCurrentChange(val) {
      this.pageObj.currentPage = val
      this.getlist(false);
    },
  },
};
</script>

<style lang="less" scoped></style>
